﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using MotoGame.Estados;

namespace MotoGame.Jogo.Estados.Menu
{
    /// <summary>
    /// Exibe o menu principal
    /// </summary>
    class Menu : EstadoBase
    {
        Botao Play;
        Botao Credit;
        Botao Sair;
        int controleTeclas;

        Texture2D textura;

        public Menu(ContentManager Content, GameWindow Window)
            : base(Content, Window)
        {
            textura = Content.Load<Texture2D>("Menu/Texturas/sapo_moto");

            Play = new Botao(Content, Window, "Menu/Texturas/play");
            Credit = new Botao(Content, Window, "Menu/Texturas/creditos");
            Sair = new Botao(Content, Window, "Menu/Texturas/sair");


            Play.posicao = new Vector2(270, 50);
            Credit.posicao = new Vector2(270, 200);
            Sair.posicao = new Vector2(270, 350);
        }

        public override void Update(GameTime gameTime)
        {
            Play.Update(gameTime);
            Credit.Update(gameTime);
            Sair.Update(gameTime);


            if (controleTeclas >= 500)
            {
                if (Game1.teclado_atual.IsKeyDown(Keys.Enter))
                {
                    Game1.estado_atual = Game1.Estado.FASE1;
                }

                if (Game1.teclado_atual.IsKeyDown(Keys.C))
                {
                    Game1.estado_atual = Game1.Estado.CREDITO;
                }
            }
            else
            { 
                controleTeclas += gameTime.ElapsedGameTime.Milliseconds; 
            }
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textura, new Rectangle(0, 0, 800, 480), Color.White);

            Credit.Draw(gameTime, spriteBatch);
            Play.Draw(gameTime, spriteBatch);
            Sair.Draw(gameTime, spriteBatch);
        }
    }
}
